using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALMenhGiaKhac
    {
        public List<MenhGiaKhac> GetAllItem()
        {
            List<MenhGiaKhac> ListMenhGiaKhac = new List<MenhGiaKhac>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] {"@Status" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString()};
            System.Data.DataSet ds = acc.CommandSelect("MenhGiaKhac_GetAllItem", sname, vname);

            MenhGiaKhac Item = new MenhGiaKhac();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListMenhGiaKhac.Add((Item.Populate(dr)));
            }
            return ListMenhGiaKhac;
        }


        public MenhGiaKhac GetMaxId()
        {
            MenhGiaKhac ItemMenhGiaKhac = new MenhGiaKhac();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("MenhGiaKhac_GetMaxId", sname, vname);

            MenhGiaKhac Item = new MenhGiaKhac();
                System.Data.DataRow dr = ds.Tables[0].Rows[0];
                return(Item.Populate(dr));
        }

        public MenhGiaKhac GetById(int Id)
        {
            MenhGiaKhac ItemMenhGiaKhac = new MenhGiaKhac();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status", "@Id" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString(), Id.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("MenhGiaKhac_GetById", sname, vname);

            MenhGiaKhac Item = new MenhGiaKhac();
            System.Data.DataRow dr = ds.Tables[0].Rows[0];
            return (Item.Populate(dr));
        }
        public int Insert_MenhGiaKhac(MenhGiaKhac Item)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@MenhGia", "@Status", "@SapXep" };
            string[] vname = new string[] {Item.LoaiMenhGia.ToString(), Common.Myconst.HOATDONG.ToString(), Item.SapXep.ToString() };
            return acc.InsertUpdateDetete("MenhGiaKhac_Insert", sname, vname);

        }

        public int Update_MenhGiaKhac(int id, String MenhGia, int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Id", "@MenhGia", "@Status", "@SapXep" };
            string[] vname = new string[] { id.ToString(), MenhGia.ToString(), Common.Myconst.HOATDONG.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("MenhGiaKhac_Update", sname, vname);

        }

        public int Delete_MenhGiaKhac(int id)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@id" };
            string[] vname = new string[] { id.ToString() };
            return acc.InsertUpdateDetete("MenhGiaKhac_Delete", sname, vname);

        }
    }
}
